Repository navigation
Conversation
`get_option()` and `get_site_option()` return the default both when an option does not exist and when their query fails, and cache the option as missing either way. `WP_Secrets_Option_Store::get()` read that as an absent secret, so during a failed read `wp_get_secret()` returned `null` for a stored secret and `wp_set_secret()` treated it as new, writing a record with no previous version. When the Options API returns the default, the store now checks the database directly. If the row exists, it returns the record and clears the cached "missing" entry. If that read fails too, it returns a `secret_store_unavailable` error, which the write path already treats as fatal. `WP_Secrets_Option_Store::delete()` now uses the same check, so it no longer reports success when it cannot tell whether the record still exists. See #66424.
Adds tests that read a network secret back after the cache is flushed, which catches a second `wp_sitemeta` row left by writing through a stale "missing" cache entry. A row with an empty or `NULL` value now reports `secret_record_malformed` rather than reading as an absent secret. See #66424.
…re-failed-read # Conflicts: # src/wp-includes/secrets/class-wp-secrets-option-store.php
wpdb::get_col() returns an empty array when its query fails, so the is_array() check in WP_Secrets_Option_Store::list_names() could never fire, and a failed listing read as no secrets. Failure is now taken from wpdb::query(), as get() does.
…ntions. Adds a summary, @Covers annotations and a unique failure message to each test, as r65272 did for the existing Secrets API tests. Asserts the result of every setup write, and uses the multisite group and skipWithoutMultisite() for the multisite-only test. Also adds a test for a failed listing in WP_Secrets_Option_Store::list_names().
…s result. wpdb::get_var() and wpdb::get_col() are called without a query, to read the result of the prepared query that wpdb::query() just ran. PHPCS reads that as an unprepared query.
On a single site, network-scope secrets are options of the site. Converting it to multisite leaves them in what becomes the main site's options table, while WP_Secrets_Option_Store reads network-scope records from wp_sitemeta, so every network secret stored before the conversion read as absent. On the main network, the store now also reads and lists them where they are. A read never moves them. The next write stores the record in wp_sitemeta and removes the old row, and a delete removes both. Follow-up to r64337. See #66686.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
This builds on #15974 (#66424), which changes the same class. Its commits come first in this branch, so please review only the last commit,
889f8c035a, until #15974 lands.On a single site, network-scope secrets are stored as options of the site. Converting it to multisite leaves those rows in what becomes the main site's options table, but
WP_Secrets_Option_Storereads network-scope records fromwp_sitemeta. So every network secret stored before the conversion read as absent:wp_get_network_secret()returnednullandwp_list_network_secrets()didn't list it.As discussed on the ticket, this leaves the records where they are rather than migrating them:
wp_sitemetaalso checks the main site's options table. Nothing is moved on a read. Other networks were created after the conversion, so they never look there.wp_sitemetaas before, and the pre-conversion row is removed. The old value becomes the previous version as usual, because a network secret's AAD contains no site or network ID.wp_sitemetaand the main site's options are combined, and each name appears once.The main site's table is read directly, with failure taken from
wpdb::query()as in #15974, so a failed read reportssecret_store_unavailableinstead of an absent secret.Testing
New multisite tests (
--group 66686). Each stores a network secret, then moves its row fromwp_sitemetainto the main site's options, as a conversion leaves it:wp_sitemeta, and the pre-conversion value becomes the previous version;Without this commit, the first six fail. The last one passes either way: it checks the fallback's scope.
--group secrets: 448 tests on single site and 464 on multisite, no failures.--group site-health: 121 tests on each, no failures.--group option: no failures. Its one warning comes from an unrelatedwp_user_settingstest and also appears on trunk.Trac ticket: https://core.trac.wordpress.org/ticket/66686
Props desrosj.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: The patch, the tests and this description. I reviewed the changes and the results.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.